import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Enemigo3 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Enemigo3 extends Enemigo
{
    int dir=1,c=0,vid=30,x;
    Boolean fallow=false;
    private static GreenfootImage[] images;
    
    public Enemigo3(){
      
        initializeImages();
        setImage(images[0]);
       
    }
    
    public synchronized static void initializeImages() 
    {
        if(images == null) {
            images = new GreenfootImage[4];
            for (int i = 0; i < 4; i++)
            {
                images[i] = new GreenfootImage("Enemigo3" + (i+1) + ".png");
            }
        }
    }
    /**
     * Act - do whatever the Enemigo2 wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
         MyWorld w = (MyWorld)getWorld();
            int x=w.getjugx();
            setImage(images[c]);
         if(fallow==false){
            if(x>getX()-150)
                fallow=true;
                dir=mover1(dir);
                if(dir<150){
                    if(dir%3==0)
                        c=2;
                    else
                        c=3;
                }
                else{
                        if(dir%3==0)
                        c=0;
                    else
                       c=1;
                }
                
            
        }
        else {
        c=getdireccion(c);
        if(c<2)
        dir=2;
        else
        dir=1;
        mover();
        Dispara(dir,3);
    }
        vid-=hit();
       if(vid<0){
       ((Score) getWorld().getObjects(Score.class).get(0)).add(30);
       getWorld().removeObject(this);
      
      }  
    }
}
